<?

////////////////////////////////
// matchrow.php
//
// DESCRIPTION:
//template snippet to output a single row for the site.
// Outputs a match name with link to match, and teams with links to teams with winner strong'ed
// 
// EXPECTS:
// $match, the Match object for the match.
// $event, the Event object for the match.
// $zebra, a zebra stripe counter
////////////////////////////////

$zebra++;
if ($match->getRedScore() == (-1)) 
    $redscore = "?";
else 
    $redscore = $match->getRedScore();

if ($match->getBlueScore() == (-1)) 
    $bluescore = "?"; 
else 
    $bluescore = $match->getBlueScore();
    
echo "<tr class=\"table_row".($zebra & 1)."\">";
//is there flash?
if ($match->getFlvPath()) {
	echo "<td>" . $match->linkto("<img src=\"" . $BASE_PATH . "images/video_icon.png\" alt=\"watch match online\">") . "</td>";
} else {
	echo "<td><img src=\"" . $BASE_PATH . "/images/download_pad.png\" alt=\"no online video available\"></td>";
} 
//is there video?
if ($match->getVidPath()) {
	echo "<td><a href=\"{$match->getVidPath()}\" title=\"Download - {$match->getName()} - {$event->getName()} ({$event->getYear()})\" class=\"downloadlink\"><img src=\"" . $BASE_PATH . "/images/download.png\" alt=\"download\"></a></td>";
} else {
	echo "<td><img src=\"" . $BASE_PATH . "images/download_pad.png\" alt=\"no download available\"></td>";
} 

//link to the video page
echo "<td>" . $match->linkto() ."</td>";

//show players and winners
$redalliance = $match->getTeams("red");
$bluealliance = $match->getTeams("blue");

if ($match->getWinner() == "red") {
	echo "<td class=\"redcell\"><strong>{$tba->linkTeam($redalliance[0], $event->getYear())}</strong></td>";
	echo "<td class=\"redcell\"><strong>{$tba->linkTeam($redalliance[1], $event->getYear())}</strong></td>";
	echo "<td class=\"redcell\"><strong>{$tba->linkTeam($redalliance[2], $event->getYear())}</strong></td>";
	echo "<td class=\"bluecell\">{$tba->linkTeam($bluealliance[0], $event->getYear())}</td>";
    echo "<td class=\"bluecell\">{$tba->linkTeam($bluealliance[1], $event->getYear())}</td>";
    echo "<td class=\"bluecell\">{$tba->linkTeam($bluealliance[2], $event->getYear())}</td>";
	echo "<td class=\"redscorecell\"><strong>" . $tba->safeScore($match->getRedScore()) . "</strong></td>";
	echo "<td class=\"bluescorecell\">" . $tba->safeScore($match->getBlueScore()) . "</td>";
} elseif ($match->getWinner() == "blue") {
	echo "<td class=\"redcell\">{$tba->linkTeam($redalliance[0], $event->getYear())}</td>";
	echo "<td class=\"redcell\">{$tba->linkTeam($redalliance[1], $event->getYear())}</td>";
	echo "<td class=\"redcell\">{$tba->linkTeam($redalliance[2], $event->getYear())}</td>";
	echo "<td class=\"bluecell\"><strong>{$tba->linkTeam($bluealliance[0], $event->getYear())}</strong></td>";
    echo "<td class=\"bluecell\"><strong>{$tba->linkTeam($bluealliance[1], $event->getYear())}</strong></td>";
    echo "<td class=\"bluecell\"><strong>{$tba->linkTeam($bluealliance[2], $event->getYear())}</strong></td>";
	echo "<td class=\"redscorecell\">" . $tba->safeScore($match->getRedScore()) . "</td>";
	echo "<td class=\"bluescorecell\"><strong>" . $tba->safeScore($match->getBlueScore()) . "</strong></td>";
} elseif ($r["bluescore"] == $r["redscore"]) {
	echo "<td class=\"redcell\">{$tba->linkTeam($redalliance[0], $event->getYear())}</td>";
	echo "<td class=\"redcell\">{$tba->linkTeam($redalliance[1], $event->getYear())}</td>";
	echo "<td class=\"redcell\">{$tba->linkTeam($redalliance[2], $event->getYear())}</td>";
	echo "<td class=\"bluecell\">{$tba->linkTeam($bluealliance[0], $event->getYear())}</td>";
    echo "<td class=\"bluecell\">{$tba->linkTeam($bluealliance[1], $event->getYear())}</td>";
    echo "<td class=\"bluecell\">{$tba->linkTeam($bluealliance[2], $event->getYear())}</td>";
	echo "<td class=\"redscorecell\">" . $tba->safeScore($match->getRedScore()) . "</td>";
	echo "<td class=\"bluescorecell\">" . $tba->safeScore($match->getBlueScore()) . "</td>";
}
echo "</tr>\r\n";

?>